from typing import NamedTuple


class GachaItem(NamedTuple):
    name: str
    rarity: int


class GachaHistory:
    __data: dict = {
        'default': {
            'sunk_cost_ssr': 0,
            'sunk_cost_sr': 0,
            'is_guaranteed': False,
            'history_items': []
        }
    }

    @classmethod
    def get_data(cls) -> dict:
        return cls.__data

    @classmethod
    def add_history(cls, user_id: str, sunk_cost_ssr: int, sunk_cost_sr: int, is_guaranteed: bool, items: list):
        if not cls.__data.get(user_id):
            cls.__data[user_id] = cls.__data.get('default')
        cls.__data[user_id]['sunk_cost_ssr'] = sunk_cost_ssr
        cls.__data[user_id]['sunk_cost_sr'] = sunk_cost_sr
        cls.__data[user_id]['is_guaranteed'] = is_guaranteed
        cls.__data[user_id]['history_items'].extend(items)

    @classmethod
    def read_history(cls, user_id: str) -> dict:
        if not cls.__data.get(user_id):
            return cls.__data.get('default', {})
        return cls.__data.get(user_id, {})
